<!doctype html>
<html>
<head>
    <meta content="webkit" name="renderer" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>HTTP-RPC控制台 - SW-X</title>
    <style>
    body,html{margin:0;padding:0;background: #f1f2f7; font-family: "微软雅黑";font-size: 16px;}
    .card-header {padding: .75rem 1.25rem;margin-bottom: 0;background-color: #fff;border-bottom: 1px solid rgba(0,0,0,.125);width:98%;}
    .card-title {margin-bottom: .75rem;}
    .table {width: 100%;margin-bottom: 1rem;background-color: transparent;}
    .table td {color: #343a40;font-size: 14px;font-weight: 600;vertical-align: middle;}
    .table th, .table td {border: none;border-bottom: 1px solid #e8e9ef;color: #868e96;font-size: 12px;font-weight: normal;padding: .25em 1.25em;}
    .table th{padding: .75em 1.25em;}
    .header td{padding: 2px 5px;}
    .content td, .content th{text-align: left;}
    .content td{background:#fff}
    .badge-complete {background: #00c292;}
    .badge {display: inline-block;padding: 10PX;font-size:13px; line-height: 1;text-align: center;white-space: nowrap;vertical-align: baseline;border-radius: .25rem;text-decoration: none;}
    select,input,button{padding: 5px 7px; border: 1px solid #ccc;border-radius: 5px;background: #fff;}

    ul,li{list-style: none;margin: 0;padding: 0;float: left;}
    ul{padding: 5px 10px; background: #fff; width: 99%;}
    ul li{margin: 0 10px;}
    ul li a{    color: #fff;
    border: 1px solid #00c292;
    text-decoration: none;
    padding: 2px 10px;
    border-radius: 5px;
    background: #00c292;
    font-family: '微软雅黑';
    font-size: 14px;}
    ul .current a{color: #333;background: #fff;border: 1px solid #00c292;}
    </style>
    <!--依赖JQ-->
    <script src="https://blog.junphp.com/public/js/jquery.min.js"></script>
    <style>
    .form-group{padding: 10px;}
    .col-md-12{width: 90%;}
    label{width: 260px;text-align: right;display: block;float: left;}
    </style>
</head>

<body>
    
<div>
    <form id="myForm">
        <div class="form-group col-md-12">
            <label>项目：</label>
            <select style="width: 355px;" name="item">
				<option value="">未定</option>
				{foreach $item as $i=>$name}
				    <option value="{$name}" {if (isset($info.item) && $info.item==$name)} selected{/if}>{$name}</option>
				{/foreach}
			</select>
        </div>
        <div class="form-group col-md-12">
            <label>分组：</label>
            <select style="width: 355px;" name="group">
				<option value="">未定</option>
				{foreach $group as $i=>$name}
				    <option value="{$name}" {if (isset($info.group) && $info.group==$name)} selected{/if}>{$name}</option>
				{/foreach}
			</select>
        </div>
        <div class="form-group col-md-12">
            <label>路由：</label>
            <input type="text" style="width: 340px;" name="class" value="{$info.class|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>接口：</label>
            <input type="text" style="width: 340px;" name="function" value="{$info.function|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>节点名称：</label>
            <input type="text" style="width: 340px;" name="title" value="{$info.title|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>TCP-IP：</label>
            <input type="text" style="width: 340px;" name="ip" value="{$info.ip|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>端口：</label>
            <input type="text" style="width: 340px;" name="port" value="{$info.port|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>初始化评分：</label>
            <input type="number" style="width: 340px;" name="score" min="0" max="100" value="{$info.score|default='100'}">
        </div>
        <div class="form-group col-md-12">
            <label>正常延迟(ms)：</label>
            <input type="number" style="width: 340px;" name="max_ms" min="0" max="10000" value="{$info.max_ms|default='200'}">
        </div>
        <div class="form-group col-md-12">
            <label>状态：</label>
            <input type="radio" name="status" value="0" {if (!isset($info['status']) || $info['status']==0)}checked{/if}>开启
            <input type="radio" name="status" value="2" {if (isset($info['status']) && $info['status']!=0)}checked{/if}>关闭
        </div>
        <div class="form-group col-md-12">
            <label>每 * 分钟内：</label>
            <input type="number" style="width: 340px;" name="route_minute" min="0" max="100000" value="{$info.route_minute|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>限制当前服务，最大接收 * 次请求：</label>
            <input type="number" style="width: 340px;" name="route_limit" min="0" value="{$info.route_limit|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>每 * 分钟内：</label>
            <input type="number" style="width: 340px;" name="ip_minute" min="0" max="100000" value="{$info.ip_minute|default=''}">
        </div>
        <div class="form-group col-md-12">
            <label>限制单个IP，最大接收 * 次请求：</label>
            <input type="number" style="width: 340px;" name="ip_limit" min="0" value="{$info.ip_limit|default=''}">
        </div>
    </form>
</div>


</body>
</html>

<script>
function _ajax(url, data, type) {
    var res;
    var process = false;
    var content = false;
    if (type == true) {
        var process = true;
        var content = true;
    }
    $.ajax({
        type: 'post',
        data: data,
        async: false,
        processData: process,
        contentType: content,
        url: url,
        success: function(data) {
            var array = eval('('+data+')');
            res = array;
            if (array['code'] == '01') {
                alert(array['msg']);
                res = false;
            }
        }
    });

    return res;
}    
// 提交
function doSubimt() {
    var data = new FormData($("#myForm")[0]);
    var res = _ajax("/HttpRpc/create_ajax", data, false);
    return res;
}
</script>